import {createRouter, createWebHistory, RouteRecordRaw} from 'vue-router';

const routes: Array<RouteRecordRaw> = [
    {
        path: '/login',
        meta: {
            title: "登录",
        },
        component: () => import('@/views/login/index.vue')
    },
    {
        path: '/',
        meta: {
            title: "首页",
        },
        component: () => import('@/components/layout/layout.vue')
    },
    {
        path: '/user',
        meta: {
            title: "用户",
            icon: "Search"
        },
        component: () => import('@/components/layout/layout.vue'),
        children: [
            {
                path: '/user',
                meta: {
                    title: "用户",
                    icon: "Location"
                },
                component: () => import('../views/user/user.vue')
            },
            {
                path: '/qadwa',
                meta: {
                    title: "we",
                    icon: "Location"
                },
                component: () => import('../views/user/qadwa.vue')
            }
        ]
    },
]

const router = createRouter({
    history: createWebHistory(),
    routes
});


// router.beforeEach((to, from, next) => {
//     let token = sessionStorage.getItem('user') ? sessionStorage.getItem('user').token : ''
//     if (to.path !== '/login' && !token) {
//         next({path: '/login'})
//     } else {
//         next()
//     }
//     return true
// })

export default router;
